From f003a4c6cc6f98c047571c5784712ba486dc17c6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 17 May 2021 23:44:28 +0200 Subject: [PATCH] gtkwindow: Simplify GTK grab notification The _gtk_widget_grab_notify() function just (maybe) did a) reset controllers and b) hide toplevels. The second part was a testing remnant introduced in commit 024d832d943, not part of the original fix. Do the former more concisely, called from the place where we figure out whether a widget's ability to receive events changed due to GTK grabs. It's across those changes that we are interested in resetting the controllers. With the gestures being reset both ways, GtkWindowHandle (and probably other) gestures are now able to reset after a GTK grab takes input away (e.g. GtkMenuButton). This could be seen as a sudden jump the next time they'd be dragged with the mouse, as the gesture would "resume" the previous interaction. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3942 --- gtk/gtkwidget.c | 28 ---------------------------- gtk/gtkwidgetprivate.h | 2 -- gtk/gtkwindow.c | 4 ++-- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index c45810a455..a7bdf8b08f 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -748,34 +748,6 @@ gtk_widget_real_contains (GtkWidget *widget, &GRAPHENE_POINT_INIT (x, y)); } -/* - * _gtk_widget_grab_notify: - * @widget: a `GtkWidget` - * @was_grabbed: whether a grab is now in effect - * - * Emits the `GtkWidget`::grab-notify signal on @widget. - */ -void -_gtk_widget_grab_notify (GtkWidget *widget, - gboolean was_grabbed) -{ - GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - GList *l; - - if (was_grabbed) - return; - - for (l = g_list_last (priv->event_controllers); l; l = l->prev) - { - GtkEventController *controller = l->data; - - gtk_event_controller_reset (controller); - } - - if (GTK_IS_NATIVE (widget)) - gtk_widget_hide (widget); -} - static void gtk_widget_real_root (GtkWidget *widget) { diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 4aee55cb6b..2863787e24 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -247,8 +247,6 @@ void _gtk_widget_set_has_grab (GtkWidget *widget, gboolean has_grab); gboolean gtk_widget_has_grab (GtkWidget *widget); -void _gtk_widget_grab_notify (GtkWidget *widget, - gboolean was_grabbed); void _gtk_widget_propagate_display_changed (GtkWidget *widget, GdkDisplay *previous_display); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index d7048ed412..add3caf85e 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6732,8 +6732,6 @@ gtk_grab_notify_foreach (GtkWidget *child, GDK_CROSSING_GTK_UNGRAB); } - _gtk_widget_grab_notify (child, was_shadowed); - g_object_unref (child); } @@ -6776,6 +6774,8 @@ gtk_window_propagate_grab_notify (GtkWindow *window, from_grab, was_shadowed, is_shadowed); + + gtk_widget_reset_controllers (l->data); } g_list_free_full (widgets, g_object_unref); -- 2.30.2